<?php
include 'qianwe.conn.php';
$action=SafeRequest('ac','get');
$CD_ID=SafeRequest('id','get');
if($action=='music'){
global $db;
$sql='select CD_Hits,CD_LastHitTime from '.tname('music').' where CD_ID='.$CD_ID.'';
$row=$db->getrow($sql);
if($row){
$daytime = time() -strtotime($row['CD_LastHitTime']);
if($daytime<86400){
$db->query('update '.tname('music')." set CD_DayHits=CD_DayHits+1 where CD_ID=$CD_ID");
}else{
$db->query('update '.tname('music')." set CD_DayHits='1' where CD_ID=$CD_ID");
}
if($daytime<86400){
$db->query('update '.tname('music')." set CD_WeekHits=CD_WeekHits+1 where CD_ID=$CD_ID");
}else{
$db->query('update '.tname('music')." set CD_WeekHits='1' where CD_ID=$CD_ID");
}
if($daytime<86400){
$db->query('update '.tname('music')." set CD_MonthHits=CD_MonthHits+1 where CD_ID=$CD_ID");
}else{
$db->query('update '.tname('music')." set CD_MonthHits='1' where CD_ID=$CD_ID");
}
$db->query('update '.tname('music')." set CD_Hits=CD_Hits+1,CD_LastHitTime='".date('Y-m-d H:i:s')."' where CD_ID=$CD_ID");
echo "document.write('".$row['CD_Hits']."');";
}else{
echo "document.write('0');";
}
}elseif($action=='favhits'){
global $db;
$sql='Select CD_FavHits from '.tname('music').' where CD_ID='.$CD_ID.'';
$row=$db->getrow($sql);
if($row){
echo "document.write('".$row['CD_FavHits']."');";
}else{
echo "document.write('0');";
}
}elseif($action=='downhits'){
global $db;
$sql='Select CD_DownHits from '.tname('music').' where CD_ID='.$CD_ID.'';
$row=$db->getrow($sql);
if($row){
echo "document.write('".$row['CD_DownHits']."');";
}else{
echo "document.write('0');";
}
}elseif($action=='special'){
global $db;
$sql='Select CD_Hits from '.tname('special')." where CD_ID=$CD_ID";
$row=$db->getrow($sql);
if($row){
$db->query('update '.tname('special')." set CD_Hits=CD_Hits+1 where CD_ID=$CD_ID");
echo "document.write('".$row['CD_Hits']."');";
}else{
echo "document.write('0');";
}
}
;echo '
';?>